unit Map;

interface

uses Engine, MapCustom, Tile;

type
  TCell = record
    ID: Byte;
//    Tile  : Tiles;
  end;

  TCells = array of array of TCell;

  TMap = class(TMapCustom)
  private
    Tile: TTiles;
    FCell: TCells;
  public
    property Cell: TCells read FCell write FCell;
    procedure Render(PCX, PCY: Integer);
    procedure Clear; override;
    function GetCell(X, Y: Integer): TCell;
    procedure SetCell(X, Y: Integer; Cell: TCell);
    procedure Save;
    procedure Load;
    procedure Gen;
    constructor Create;
    destructor Destroy; override;
  end;

implementation

{ TMap }

procedure TMap.Clear;
var
  X, Y: Integer;
begin
  for X := 0 to Width - 1 do
    for Y := 0 to Height - 1 do ;
//      SetCell(X, Y, 0);

end;

constructor TMap.Create;
begin
  inherited;
  Tile := TTiles.Create;
end;

destructor TMap.Destroy;
begin
  Tile.Free;
  inherited;
end;

function TMap.GetCell(X, Y: Integer): TCell;
begin
  Result := FCell[Y][X];
end;

procedure TMap.Render(PCX, PCY: Integer);
var
  DX, DY, X, Y: Integer;
begin
  MAP_TOP := PCY - GAME_SCR_HEIGHT div 2;
  MAP_LEFT := PCX - GAME_SCR_WIDTH div 2;

  for Y := -1 to GAME_SCR_HEIGHT do
    for X := -1 to GAME_SCR_WIDTH do
      Tile.Render(X, Y, 0);
      //{GetCell(X + Left, Y + Top).ID});
end;

procedure TMap.Gen;
begin

end;

procedure TMap.Load;
begin

end;

procedure TMap.Save;
begin

end;

procedure TMap.SetCell(X, Y: Integer; Cell: TCell);
begin
  FCell[Y][X] := Cell;
end;

end.
